<template>
  <div>
    <h1>当前求和为：{{ sum }}</h1>
    <h1>当前求和放大10倍为：{{ bigSum }}</h1>
    <h1>我在{{ school }}学{{ subject }}</h1>
    <h1>下方组件的总人数是{{personList.length}}</h1>
    <select v-model="number">
      <option :value="1">1</option>
      <option :value="2">2</option>
      <option :value="3">3</option>
    </select>
    <button @click="increment(number)">+</button>
    <button @click="decrement">-</button>
    <!--<button @click="ADD(number)">+</button>-->
    <!--<button @click="DEL(number)">-</button>-->
    <!--<button @click="incrementOdd(number)">当前求和为奇数再加</button>-->
    <!--<button @click="incrementWait(number)">等一等再加</button>-->
    <button @click="addOdd(number)">当前求和为奇数再加</button>
    <button @click="addWait(number)">等一等再加</button>
  </div>
</template>

<script>
import {mapGetters, mapState, mapMutations, mapActions} from 'vuex'

export default {
  name: "Count",
  description: '',
  mixins: [],
  components: {},
  props: [],
  data() {
    return {
      number: 1,
    }
  },
  computed: {
    ...mapState('countOptions',['sum', 'school', 'subject']),
    ...mapState('personOptions',['personList']),
    ...mapGetters('countOptions',['bigSum'])
  },
  watch: {},
  filters: {},
  created() {
  },
  mounted() {
  },
  destroyed() {
  },
  methods: {
    ...mapMutations('countOptions',{increment: 'ADD', jian: 'DEL'}),
    /*
    * 相当于创建了一个这样的函数
    * */
    jian(value){
      this.$store.commit('DEL', value)
    },
    decrement() {
      this.jian(this.number)
    },
    ...mapActions('countOptions',['addOdd','addWait'])

  }
}
</script>

<style scoped>
button {
  margin: 0 10px;
}
</style>